// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Framework/BaseGameInstance.h"
#include "Data/GameInstanceInterface.h"
#include "Data/SaveInfoStruct.h"
#include "GMSGameInstance.generated.h"

class UWidget;
class USlotBasedSaveGame;
UCLASS()
class MISCELLANEOUSPROJECT_API UGMSGameInstance : public UBaseGameInstance,public IGameInstanceInterface
{
	GENERATED_BODY()
public:
	UGMSGameInstance();
	//=============Interface Function=========================
	//=================Game===================
	virtual EGameState PassGameState();
	virtual bool UpdateGameState(const EGameState& DesiredGameState);
	virtual void GetGameWidgets(class UWidget*& OutBeginPlayWidget, class UWidget*& OutMainMenuWidget, class UWidget*& OutPauseMenuWidget,
		class UWidget*& OutLoadingScreenWidget, class UInGameWidget*& OutInGameWidget, class UInGameMenuWidget*& OutInGameMenuWidget);
	virtual void StartNewGame(const FSavedGameplayInfo& GameplayInfo, const FName& LevelName);
	virtual void OnAnyKey(FKey& AnyKey);
	//================Gameplay==============
	virtual void Request_Open_Level(const ELevelType& LevelType, const FName& LevelName, const FString& LoadedSlot);
	//================Save Game Library===========
	virtual FString GetDefaultSlotName();
	virtual bool SetCurrentSlot(const FString& CurrentSlot);
	virtual FString GetCurrentSlot();

	virtual FSavedMissionComponent& GetMissionCSaveReference();
	virtual bool UpdateMissionCSaveReference(FSavedMissionComponent& MissionComponent);

	virtual FSavedGameplayInfo& GetGameplaySaveDataReference();
	virtual bool UpdatePlayerSaveDataReference(const FSavedPlayerInfo& PlayerInfo);

	virtual FSavedPlayerInfo& GetPlayerSaveDataReference();
	virtual bool SetGameplaySaveDataReference(const FSavedGameplayInfo& GameplayInfo);

	virtual bool SaveCurrentProgress();
	virtual bool LoadSavedGame(const FString& FromSlot);
	//===============Widget Events======================
	virtual void DisplayGameWidget(const EGameState& GameState);
	virtual void HideLoadingScreen(const float& Delay);
	virtual void TogglePauseMenu();
	virtual void ToggleInGameMenu(const EInGameMenuType& MenuType);
	//=============================================================
	
public:
	//========Main=============
	EGameState CurrentGameState;
	bool IsBeginPlay;
	//=====Widgets===========
	UWidget* LoadingScreenWidget;
	UUserWidget* BeginPlayWidgte;
	UWidget* MainMenuWidget;
	UInGameWidget* InGameWidget;
	UWidget* PauseMenuWidget;
	UInGameMenuWidget* InGameMenuWidget;
	//=======SaveGame===========
	//==========Reference========
	USlotBasedSaveGame* SaveGameObject;
	FString CurrentSlotName;
	//============Default========
	FString DefaultSaveSlotName;
	//========Info To Save==========
	FSavedPlayerInfo PlayerInfoToSave;
	FSavedGameplayInfo GameplayInfoToSave;
	FSavedMissionComponent MissionComponentToSave;
};
